<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class Index extends Controller
{
    public function _initialize(){
        //首先验证token
        $token = input('token');
        $time  = time();
        $map['token'] = $token;
        $res = Db::name('token')->where($map)->find();

        if($res==null){

            exit(error(30001,'无效的token'));
        }else{
            if($res['out_time']+7200>time()){
                exit(error(30001,'token过期'));
            }
        }
        parent::_initialize();
    }
    public function index()
    {
        return 211111121;
    }
    public function test(){
        echo 'test';
    }
}
